package com.wuxiaofan.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wuxiaofan.entity.OrderInfo;
import com.wuxiaofan.entity.custom.OrderInfoCustom;
import com.wuxiaofan.mapper.OrderInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.wuxiaofan.config.Idgenerator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;

@Service
public class OrderInfoService {
    @Autowired
    private OrderInfoMapper orderInfoMapper;
    @Resource
    private Idgenerator idgenerator;
    public OrderInfo findById(String id){
        return orderInfoMapper.selectById(id);
    }

    public OrderInfoCustom findCountByMap(Map paraMap){
        return orderInfoMapper.findCountByMap(paraMap);
    }

    public OrderInfoCustom findGroupByMap(Map paraMap){
        return orderInfoMapper.findGroupByMap(paraMap);
    }

    public List<OrderInfoCustom> findByMap(Map paraMap){
        return orderInfoMapper.findByMap(paraMap);
    }

    public Page<OrderInfoCustom> findByMap(Map paraMap, Page page){
        return page.setRecords(orderInfoMapper.findByMap(paraMap,page));
    }


    public void updateMapById(Map paraMap){
        orderInfoMapper.updateMapById(paraMap);
    }
    public void delById(String id){
        orderInfoMapper.deleteById(id);
    }

    public OrderInfo save(OrderInfo orderInfo){
        orderInfo.setId(idgenerator.getId());
        orderInfoMapper.insert(orderInfo);
        return orderInfo;
    }

}
